package com.binest.hackathonInclusion.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.binest.kolInclusion.domain.KolInclusion;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.binest.common.annotation.Log;
import com.binest.common.core.controller.BaseController;
import com.binest.common.core.domain.AjaxResult;
import com.binest.common.enums.BusinessType;
import com.binest.hackathonInclusion.domain.HackathonInclusion;
import com.binest.hackathonInclusion.service.IHackathonInclusionService;
import com.binest.common.utils.poi.ExcelUtil;
import com.binest.common.core.page.TableDataInfo;

/**
 * 黑客马拉松收录Controller
 * 
 * @author wwd
 * @date 2024-01-19
 */
@RestController
@RequestMapping("/hackathonInclusion")
public class HackathonInclusionController extends BaseController
{
    @Autowired
    private IHackathonInclusionService hackathonInclusionService;

    /**
     * 查询黑客马拉松收录列表
     */
    @PreAuthorize("@ss.hasPermi('hackathonInclusion:hackathonInclusion:list')")
    @GetMapping("/list")
    public TableDataInfo list(HackathonInclusion hackathonInclusion)
    {
        startPage();
        List<HackathonInclusion> list = hackathonInclusionService.selectHackathonInclusionList(hackathonInclusion);
        return getDataTable(list);
    }


    /**
     * 查询es中黑客马拉松收录列表
     */
    @GetMapping("/esList")
    public TableDataInfo esList(HackathonInclusion hackathonInclusion) throws Exception {

        TableDataInfo list = hackathonInclusionService.selectHackathonInclusionEsList(hackathonInclusion);
        return list;
    }


    /**
     * 导出黑客马拉松收录列表
     */
    @PreAuthorize("@ss.hasPermi('hackathonInclusion:hackathonInclusion:export')")
    @Log(title = "黑客马拉松收录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HackathonInclusion hackathonInclusion)
    {
        List<HackathonInclusion> list = hackathonInclusionService.selectHackathonInclusionList(hackathonInclusion);
        ExcelUtil<HackathonInclusion> util = new ExcelUtil<HackathonInclusion>(HackathonInclusion.class);
        util.exportExcel(response, list, "黑客马拉松收录数据");
    }

    /**
     * 获取黑客马拉松收录详细信息
     */
    @PreAuthorize("@ss.hasPermi('hackathonInclusion:hackathonInclusion:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(hackathonInclusionService.selectHackathonInclusionById(id));
    }

    /**
     * 获取es中黑客马拉松收录详细信息
     */
    @GetMapping(value = "/getEsInfo")
    public AjaxResult getEsInfo(String id) throws Exception {
        return success(hackathonInclusionService.selectEsHackathonInclusionById(id));
    }

    /**
     * 新增黑客马拉松收录
     */
    @PreAuthorize("@ss.hasPermi('hackathonInclusion:hackathonInclusion:add')")
    @Log(title = "黑客马拉松收录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody HackathonInclusion hackathonInclusion)
    {
        return success(hackathonInclusionService.insertHackathonInclusion(hackathonInclusion));
    }

    /**
     * 修改黑客马拉松收录
     */
    @PreAuthorize("@ss.hasPermi('hackathonInclusion:hackathonInclusion:edit')")
    @Log(title = "黑客马拉松收录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HackathonInclusion hackathonInclusion)
    {
        return toAjax(hackathonInclusionService.updateHackathonInclusion(hackathonInclusion));
    }

    /**
     * 删除黑客马拉松收录
     */
    @PreAuthorize("@ss.hasPermi('hackathonInclusion:hackathonInclusion:remove')")
    @Log(title = "黑客马拉松收录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(hackathonInclusionService.deleteHackathonInclusionByIds(ids));
    }
}
